#include "PreProcFileTests.hpp"
#include "../IfDefDirective.hpp"
#include "../Macro.hpp"

namespace CPreProc
{
  Glib::RefPtr<Group> PreProcFileTests::create_ifdef_test_file()
  {
    Glib::RefPtr<Group> group = Glib::RefPtr<Group>(new Group);

    Glib::RefPtr<IfSection> ifdef_section = Glib::RefPtr<IfSection>(new IfSection);
    group->group_parts.push_back(ifdef_section);

    Glib::RefPtr<IfGroup> ifdef_group = Glib::RefPtr<IfGroup>(new IfGroup);
    ifdef_section->if_groups.push_back(ifdef_group);

    Glib::RefPtr<IfDefCondition> condition = Glib::RefPtr<IfDefCondition>(
      new IfDefCondition("SYMBOL",false));
    ifdef_group->condition = condition;

    ifdef_group->group_parts.push_back(Glib::RefPtr<ErrorDirective>(new ErrorDirective("A")));

    Glib::RefPtr<IfGroup> else_group = Glib::RefPtr<IfGroup>(new IfGroup);
    ifdef_section->if_groups.push_back(else_group);
    else_group->group_parts.push_back(Glib::RefPtr<ErrorDirective>(new ErrorDirective("B")));

    return group;
  }

  void PreProcFileTests::test_ifdef()
  {
    Glib::RefPtr<Group> group = create_ifdef_test_file();
    
    {
      PreProcessorContext context;
      context.process_group(group);
    }

    {
      PreProcessorContext context;
      context.define_macro("SYMBOL");
      context.process_group(group);
    }
  }
}

